<div class="container-fluid" style="margin: 0px 15px 0px 15px;">
<ol class="breadcrumb">
  <li><a href="<?php echo base_url('/index.php/inicio');?>">Início</a></li>
  <li><a href="<?php echo base_url('index.php/usuarios/consulta');?>">Usuário</a></li>
  <li class="active">Info</li>
</ol>
<!-- Nav tabs -->
<!--<ul class="nav nav-tabs" role="tablist">-->
<ul class="nav nav-pills">
  <li class="active"><a href="#info" role="tab" data-toggle="tab">Info</a></li>
  <li><a href="#historico" role="tab" data-toggle="tab">Histórico Férias</a></li>
</ul>

<!-- Tab panes -->
<div class="tab-content">
<div class="tab-pane active" id="info">
		<br/>
		<fieldset>
			<legend>Info Usuário</legend>
			<form class="form-horizontal" role="form" id="form">
				<input type="hidden" name="id" id="id" value="<?php echo $usuario->id ?>" />
				<div class="form-group">
				<label for="inputEmail3" class="col-sm-2 control-label">Login</label>
				<div class="col-sm-2">
					<?php 
						$data = array('disabled'=>'disabled','name'=> 'login','id'=> 'login','value'=> @$usuario->login,'placeholder'=> 'Login','class'=> 'form-control input-sm');
						echo form_input($data);
					?>
				</div>
				</div>
				<div class="form-group">
				<label for="inputPassword3" class="col-sm-2 control-label">Nome Completo</label>
				<div class="col-sm-4">
					<?php 
						$data = array('disabled'=>'disabled','name'=> 'nome','id'=> 'nome','value'=> @$usuario->nome_completo,'placeholder'=> 'Nome Completo','class'=> 'form-control input-sm');
						echo form_input($data);
					?>
				</div>
				</div>
				<div class="form-group">
				<div class="col-sm-offset-2 col-sm-2">
				  <div class="checkbox">
					<label>
					<?php
						if($usuario->status == '1'){
							$status = TRUE;
						}else{
							$status = FALSE;
						}
						echo form_checkbox('status', '1', $status,'disabled=disabled');
						
					 ?>
					 Ativo
					</label>
				  </div>
				</div>
				</div>
				<div class="form-group">
				<label for="inputPassword3" class="col-sm-2 control-label">Permissão</label>
				<div class="col-sm-2">
					<?php 
						echo form_dropdown('permissao',$permissao,$usuario->permissao_id,'class="form-control" disabled="disabled"');
						
					?>
				</div>
				
				</div>
							
				<div class="form-group">
				<label for="inputPassword3" class="col-sm-2 control-label">Observação</label>
				<div class="col-sm-4">
					<?php 
						$data = array('disabled'=>'disabled','name'=> 'observacao','id'=> 'observacao','placeholder'=> 'Observação','class'=> 'form-control input-sm', 'value'=> @$usuario->observacao,'rows'=>'3');
						echo form_textarea($data);
					?>
				</div>
				</div>

				<div class="form-group">
					<div class="col-sm-offset-2 col-sm-10">
					<?php 
						$data = array('name'=>'salvar','type' => 'submit','class' => 'btn btn-primary','content' =>'Salvar');
						echo form_button($data);
				
					?>
						<a id="cancelar" href="<?php echo base_url('index.php/usuarios/consulta');?>" class="btn btn-default"></span>Cancelar</a>
						<a id="editar" href="#" class="btn btn-warning"></span>Editar</a>
					</div>
				</div>

			</form>
			<div id="retorno1"></div>
			</fieldset>
</div>
<div class="tab-pane" id="historico">
<br/>
<table id="example" class="display responsive nowrap" cellspacing="0" width="100%">
      <thead>
        <tr>
          <th>Tipo</th>
          <th>Data Início</th>
          <th>Data Fim</th>
          <th>Obsservação</th>
        </tr>
      </thead>
      <tbody>
<?php
		$count = 1;
		foreach($ausente as $au){
			echo '<tr>';
			$tipo = '';
			switch($au->tipo){
				case 'A': $tipo ="AFASTAMENTO";break;
				case 'F': $tipo ="FÉRIAS";break;
				case 'L': $tipo ="LICENÇA";break;
				case 'O': $tipo ="OUTROS";break;
			}
			echo '<td>'.$tipo.'</td>';
			echo '<td>'.usaToBr($au->dt_inicio).'</td>';
			echo '<td>'.usaToBr($au->dt_fim).'</td>';
			echo '<td>'.$au->observacao.'</td>';
			echo '</tr>';
		
		}
?>
	  
      </tbody>
    </table>
</div>
</div>
</div>
	<script language="javascript" type="text/javascript">
		$(document).ready(function(){
			$('table.display').DataTable({
				"order": [[ 1, "desc" ]],
				"language": {
					"url": "<?php echo base_url('includes/js/Portuguese-Brasil.json'); ?>"
				},
				"pagingType": "simple"
			});

			var form = $("#form");
			$('#editar').click(function(event) {
				$('#divparte').show();
				$('#divassunto').show();
				event.preventDefault();
				form.find(':disabled').each(function() {
					$(this).removeAttr('disabled');
				});
			});
			$("#form").validate({
				rules: {
					login: "required",
					nome: "required",
					permissao: "required"
				},
				messages: {
					login: "Campo requerido",
					nome: "Campo requerido",
					permissao: "Campo requerido"
				},
				submitHandler: function(form){
					var dados = $('#form').serialize();
					$.ajax({
						type: "POST",
						url: "<?php echo base_url('index.php/usuarios/editar'); ?>",
						data: dados,
						success: function( data )
						{
							$("html, body").animate({ scrollTop: $(document).height() }, "slow");
							if(data === 'OK'){
								
								$('#retorno1').html('<div class="alert alert-success" role="alert">CADASTRO ATUALIZADO COM SUCESSO</div>');
								setTimeout(function() {
									$('#retorno1').html('');
								}, 2000);
							}else{
								$('#retorno1').html(data);
							}
						},
						statusCode: {
							404: function() {
								alertify.error("Pagina nao encontrada");
							}
						}
					});
					return false;
				}
			});

		});
	</script>
</body>
</html>